package com.cac.demo.service.backReceive;

import com.cac.demo.dao.backReceive.BackReceiveDao;


import com.cac.demo.util.adapter.DaoException;
import com.cac.demo.util.adapter.QueryReqBean;
import com.cac.demo.util.adapter.QueryRespBean;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class BackReceiveService {

    @Autowired
    private BackReceiveDao backReceiveDao;


    //查询MES退库的交接单
    public QueryRespBean<HashMap> searchBackMaterial(QueryReqBean<HashMap> queryReqBean, HashMap searchParams) {
        QueryRespBean<HashMap> queryRespBean = new QueryRespBean<>();
        try {
            PageHelper.startPage(queryReqBean.getPageParameter());
            Page<HashMap> dataList = backReceiveDao.searchBackMaterial(searchParams);
            queryRespBean.setResult(dataList);
            return queryRespBean;
        } catch (Exception e) {
            throw new DaoException(e.getMessage());
        }
    }

    public List<HashMap> searchBackMaterialByBarcode(String barcode){
        return backReceiveDao.searchBackMaterialByBarcode(barcode);
    }

    //退库接收改变接收状态
    public int changeBackType(String barcode, String account,int returnQty,String IP,String id,String status) {
        int result=backReceiveDao.changeBackType(barcode, account,returnQty,IP,id,status);
        return result;
    }

    //退库接收生成叫箱数据
    public int insertReceDetail(String id) {
        int result=backReceiveDao.insertReceDetail(id);
        return result;
    }
}
